package com.hubu.admin.interceptor;

import com.hubu.admin.utils.JwtUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;

public class TokenInterceptor implements HandlerInterceptor {

    @Resource
    private JwtUtils jwtUtils;
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        //HttpServletResponseWrapper httpServletResponseWrapper = new HttpServletResponseWrapper(response);
        String token = request.getHeader("token");
        System.out.println("token:"+token);
        if(StringUtils.isEmpty(token)){
            return false;
        }
        return true;


    }
}
